import { useEffect, useState } from "react";
import { fetchChannelsApi } from "@/apis/article";
function useChannels() {
  const [channels, setChannels] = useState([]);
  useEffect(() => {
    // 封装函数   在函数体内调用接口
    async function getChannelList() {
      const res = await fetchChannelsApi();
      setChannels(res.data.channels);
    }
    // 调用函数
    getChannelList();
  }, []);
  return {
    channels,
  };
}
export { useChannels };
